package com.subway.babynote;

/*水*/
import com.subway.babynote.syncdata.ClientDataRecord.usersRecord;
import com.subway.babynote.syncdata.StringUtil;
import com.subway.babynote.syncservice.syncapi;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.database.Cursor;

public class myinfo extends Activity {
	private static final int INVISIBLE = 0x00000004;
	Button modify_button;
	Button more_button;
	Button login_button;
	TextView email_view;
	TextView birth_view;
	TextView gender_view;
	NotedbHelper notedb;
	Cursor cur;
	int col;
	Intent In;
	private LinearLayout linearLayout, statistics, sync, more;

	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.myinfo);
		setTitle(R.string.myinfotitle);
		email_view = (TextView) findViewById(R.id.email_view);
		birth_view = (TextView) findViewById(R.id.birth_view);
		gender_view = (TextView) findViewById(R.id.gender_view);
		modify_button = (Button) findViewById(R.id.modify_button);
		more_button = (Button) findViewById(R.id.more_button);
		login_button = (Button) findViewById(R.id.login_button);
		In = new Intent();
		notedb = new NotedbHelper(this);
		// initTabFunction();
		try {
			if (syncapi.getSyncImpl().getUser().isuser) {
				login_button.setVisibility(INVISIBLE);
				login_button.setClickable(false);
			}
			usersRecord rc = syncapi.getSyncImpl().getUser();
			if (rc != null) {

				email_view.setText(rc.email);
				birth_view.setText(StringUtil.sql_date2str(
						StringUtil.int2date(rc.birth)).substring(0, 11));

				if (!rc.gender) {
					gender_view.setText(getResources().getString(
							R.string.female));
				} else {
					gender_view
							.setText(getResources().getString(R.string.male));
				}
			}
		} catch (Exception e) {
			Log.v("myinfo", "get info from DB e=" + e.getMessage());
		}

		modify_button.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {

				In.setClass(myinfo.this, birth.class);
				startActivity(In);
			}
		});
		more_button.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {

				In.setClass(myinfo.this, maintab.class);
				startActivity(In);
			}
		});
		login_button.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {

				In.setClass(myinfo.this, login.class);
				startActivity(In);
			}
		});
	}

	public void onDestroy() {
		notedb.close();
		super.onDestroy();
	}
}